<template>
<div>
	<h3 class="base-title">典型表单</h3>
	<p class="base-content">包括各种表单项，比如输入框、选择器、开关、单选框、多选框等。</p>

	<div class="demo-block" :class="{'show-case-core':caseObj1.showCoreFlag}">
		<div class="demo-block-source">
			<bh-form ref="form" :model="form" label-width="80px">
				<bh-form-item label="活动名称">
					<bh-input v-model="form.name1"></bh-input>
				</bh-form-item>
				<bh-form-item label="活动区域">
					<bh-input v-model="form.name2"></bh-input>
				</bh-form-item>
				<bh-form-item>
					<bh-button type="primary" @click="onSubmit">立即创建</bh-button>
					<bh-button>取消</bh-button>
				</bh-form-item>
			</bh-form>
		</div>
		<div class="demo-block-core">
			<textarea class="demo-core-box" readonly="readonly" v-model="caseSourceVal" style='height: 400px;'></textarea>
		</div>
		<div class="demo-block-footer">
			<div class="demo-ms-arr" @click='toggleDemoCore(caseObj1)'>
				<span class="demo-ms-s">显示代码</span>
				<span class="demo-ms-h">隐藏代码</span>
			</div>
			<a :href="caseObj1.coreUrl" target="_blank" class="demo-online" title="前往 codepen.io 运行此示例">在线运行</a>
		</div>
	</div>
</div>
</template>

<script>
const caseSourceVal = `
<bh-form ref="form" :model="form" label-width="80px">
	<bh-form-item label="活动名称">
		<bh-input v-model="form.name1"></bh-input>
	</bh-form-item>
	<bh-form-item label="活动区域">
		<bh-input v-model="form.name2"></bh-input>
	</bh-form-item>
	<bh-form-item>
		<bh-button type="primary" @click="onSubmit">立即创建</bh-button>
		<bh-button>取消</bh-button>
	</bh-form-item>
</bh-form>
export default {
	data () {
		return {
			form: {
				name1: '11',
				name2: '22',
			},
		};
	},
	methods: {
		onSubmit () {
			console.log('onSubmit');
		},
	},
}
`;
export default {
	data () {
		return {
			caseObj1: {
				showCoreFlag: false,
				coreUrl: 'https://codepen.io/xiebaolin/pen/XWaJPjv',
			},
			caseSourceVal: caseSourceVal,

			form: {
				name1: '11',
				name2: '22',
			},
		};
	},
	methods: {
		// 切换代码显隐
		toggleDemoCore (item) {
			item.showCoreFlag = !item.showCoreFlag;
		},

		onSubmit () {
			console.log('onSubmit');
		},
	},
}
</script>

<style scoped>
</style>
